

//1.基本解构语法

let prisonFriends = ["李易峰", "吴签", "黄海波", "李云迪"]

let [f1] = prisonFriends;

//console.log(f1) //李易峰

//2.解构指定元素

let [, f2] = prisonFriends

//console.log(f2) //吴签


//3.解构多维数组

let prisonFriends2 = ["李易峰", "吴签", ["房祖名", "张默", "柯震东"], "黄海波", "李云迪"]

let [, , [, , f3]] = prisonFriends2;

//console.log(f3) //柯震东

//4.剩余元素


let [f4, ...f6] = prisonFriends2

console.log(f4, f6)

//剩余元素编写的时候要注意 剩余元素必须放在最后

// let [f7, ...f8, f9] = prisonFriends2 错误的写法


//5.对象和数组的混合解构

let node = {
    personalInfo: {
        basicInfo: {
            name: {
                firstName: 'mike',
                lastName: 'deep'
            },
        }
    },
    levelRange: [1, 3]
};

let { personalInfo: { basicInfo: { name: { lastName } } }, levelRange: [, b] } = node;

console.log(lastName) //deep

console.log(b)//3